import instacne from "../request";

// 退货申请处理表格数据   /returnApply/list
// 查询
interface IReturnApplyParams {
  createTime?: string;
  handleMan?: string;
  id?: number | null;
  pageNum?: number;
  pageSize?: number;
  receiverKeyword?: string;
  status?: string | number;
  handleTime?: string;
}
interface IReturnApplyItem {
  companyAddressId: number;
  createTime: string;
  description: string;
  handleMan: string;
  handleNote: string;
  handleTime: string;
  id: number;
  memberUsername: string;
  orderId: number;
  orderSn: string;
  productAttr: string;
  productBrand: string;
  productCount: number;
  productId: number;
  productName: string;
  productPic: string;
  productPrice: number;
  productRealPrice: number;
  proofPics: string;
  reason: string;
  receiveMan: string;
  receiveNote: string;
  receiveTime: string;
  returnAmount: number;
  returnName: string;
  returnPhone: string;
  status: number;
}
interface IReturnApplyRes {
  list: any | IReturnApplyItem[];
  pageNum: number;
  pageSize: number;
  total: number;
  totalPage: number;
}
// 分页查询退货申请
const returnApplyList = (
  data?: IReturnApplyParams
): Promise<IReturnApplyRes> => {
  return instacne.get("/returnApply/list", {
    params: data,
  });
};

interface IcompanyAddressPromise {
  addressName: string;
  city: string;
  detailAddress: string;
  id: number;
  name: string;
  phone: string;
  province: string;
  receiveStatus: null | number;
  region: string;
  sendStatus: null | number;
}

interface IreturnDetailPromise {
  companyAddress: IcompanyAddressPromise;
  companyAddressId: number;
  createTime: string;
  description: string;
  handleMan: string;
  handleNote: string;
  handleTime: string;
  id: number;
  memberUsername: string;
  orderId: number;
  orderSn: string;
  productAttr: string;
  productBrand: string;
  productCount: number;
  productId: number;
  productName: string;
  productPic: string;
  productPrice: number;
  productRealPrice: number;
  proofPics: string;
  reason: string;
  receiveMan: string;
  receiveNote: string;
  receiveTime: string;
  returnAmount: number;
  returnName: string;
  returnPhone: string;
  status: number;
}

// 退货申请处理查看详情   /returnApply/4
const returnDetail = (data: string | number): Promise<IreturnDetailPromise> => {
  return instacne.get(`/returnApply/${data}`);
};

// 批量删除退货申请
// const returnApplyDelete = (
//   data: string | number
// ): Promise<IreturnDetailPromise> => {
//   return instacne.get("/returnApply/delete", { data });
// };
const returnApplyDelete = (data: any) => {
  return instacne.post(`/returnApply/delete?ids=${data}`);
};

export { returnApplyList, returnDetail, returnApplyDelete };
export type {
  IReturnApplyItem,
  IReturnApplyRes,
  IReturnApplyParams,
  IreturnDetailPromise,
  IcompanyAddressPromise,
};
